// INCLUDES --------------------------------------------------------------------
#include "Base.h"

// FUNCTIONS -------------------------------------------------------------------

/* fill copy function for lining up structs in a memory area.
   
   dest     -> destination memory (NEEDS TO BE OF ADEQUATE BYTE SIZE!!)
   src      -> src pointer to the struct
   byteSize -> byte size of the source struct
   amount   -> amount of copies that need to be lined up

   output will add up the src to look like this in dest memory:

   dest:     |           |
   src:      |A|
   byteSize: *someByteSize*
   amount:   5

   RESULT:   |AAAAA      |
*/
void FillCopy(void *dest, void *src, ui32 byteSize, ui32 amount)
{
  GUARD_NULL("FillCopy *dest", dest);
  GUARD_NULL("FillCopy *src", src);

  // check for a >0 byteSize of the source struct
  if (byteSize == 0) return;

  // clamp range to at least one element
  CLAMP_LOW(amount, 1);

  // now line up the structs in the destination memory
  ui32 calculatedDest = (ui32)dest,
       i = 0;

  printf("base: %i\n", calculatedDest);

  for (i = 0; i < amount; i++)
  {
    calculatedDest += byteSize*i;
    printf("%i\n", calculatedDest);
    memcpy((void*)calculatedDest, src, byteSize);
  };
};
